from save import Save
import random
import time

class SaveData:
    def __init__(self) -> None:
        self.startTime = 0
        self.endTime = 0

        self.seed = 0

    def toSave(self, save:Save) -> None:
        if not save.data.get("startTime"): # 没有初始化开始时间
            self.startTime = time.time()
        save.data["startTime"] = self.startTime

        if self.endTime: save.data["endTime"] = self.endTime

        if not save.data.get("seed"): # 没有初始化种子
            self.seed = random.randint(-2**31,2**31-1)
        
        save.data["seed"] = self.seed
        

    def fromSave(self, save:Save) -> None:
        self.startTime = save.data["startTime"]

        self.seed = save.data["seed"]